Improve the Pattern-detection in CanvasGraphics.stroke
#12591
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The vast majority of the time, unless a Pattern is active, the
strokeColor
-property contains a "simple" colour value represented by a String. Hence it seems somewhat ridiculous to do ahasOwnProperty
check on a String, and it's should thus be possible to improve things a tiny bit here.Unfortunately using a simple
instanceof
check would only work forTilingPattern
s, but not for theShadingIRs
given how they are implemented; seesrc/display/pattern_helper.js
. (While that file could probably do with some clean-up, given the age of some of its code, that probably shouldn't happen here.)Finally, the
this.type = "Pattern"
-property of the various Shadings/TilingPatterns were removed, since I cannot see why it's necessary when we can simply check for agetPattern
method instead. Note that part of this code even pre-dates the main/worker-thread split, which probably in part explains why it looks the way it does.